using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using MatrixFramework.Shared.Contracts.Monitoring;

namespace MatrixFramework.Shared.HttpApi.Controllers
{
    /// <summary>
    /// 指标控制器
    /// 提供标准的指标API接口
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    [Produces("application/json")]
    public class MetricsController : AbpControllerBase
    {
        private readonly IMetricsAppService _metricsAppService;

        public MetricsController(IMetricsAppService metricsAppService)
        {
            _metricsAppService = metricsAppService;
        }

        /// <summary>
        /// 获取系统指标摘要
        /// </summary>
        /// <param name="input">查询参数</param>
        /// <returns>指标摘要</returns>
        [HttpGet("summary")]
        public async Task<MetricsSummaryDto> GetSummaryAsync([FromQuery] GetMetricsInput input)
        {
            return await _metricsAppService.GetSummaryAsync(input);
        }

        /// <summary>
        /// 获取指标详情
        /// </summary>
        /// <param name="metricName">指标名称</param>
        /// <param name="input">查询参数</param>
        /// <returns>指标详情</returns>
        [HttpGet("{metricName}")]
        public async Task<MetricDetailsDto> GetDetailsAsync(string metricName, [FromQuery] GetMetricDetailsInput input)
        {
            return await _metricsAppService.GetDetailsAsync(metricName, input);
        }

        /// <summary>
        /// 获取性能指标
        /// </summary>
        /// <param name="input">查询参数</param>
        /// <returns>性能指标</returns>
        [HttpGet("performance")]
        public async Task<PerformanceMetricsDto> GetPerformanceMetricsAsync([FromQuery] GetPerformanceMetricsInput input)
        {
            return await _metricsAppService.GetPerformanceMetricsAsync(input);
        }
    }
}